# RVC Controller SW — System Sequence Diagrams (SSD)

| 항목 | 내용 |
|------|------|
| 문서 번호 | RVC-SSD-001 |
| 버전 | v1.3 |
| 작성일 | 2026-05-19 |
| 작성자 | OOAD Team |
| 상태 | 초안 (Draft) |

---

## 변경 이력 (Change History)

| 버전 | 날짜 | 변경 내용 | 작성자 |
|------|------|-----------|--------|
| v1.0 | 2026-05-19 | 최초 작성 — SSD 5개 (시나리오 묶음) | OOAD Team |
| v1.1 | 2026-05-19 | UC 8개와 1:1 대응하도록 SSD 8개로 재구성 | OOAD Team |
| v1.2 | 2026-05-19 | 각 SSD 섹션에 PNG 이미지 삽입 | OOAD Team |
| v1.3 | 2026-05-19 | PlantUML 코드블록 및 .mmd 파일에서 모든 note 제거, PNG 재생성 | OOAD Team |

---

## 개요

SSD(System Sequence Diagram)는 시스템을 **블랙박스**로 취급하여  
외부 Actor의 자극(Stimulus)과 시스템의 응답(Response) 흐름을 표현한다.  
각 SSD는 Use Case와 **1:1 대응**한다.

| SSD ID | 대응 UC | Use Case 명 | 트리거 Actor |
|--------|---------|-------------|-------------|
| SSD-01 | UC-01 | Perform Normal Cleaning | RVC System (자체 시작) |
| SSD-02 | UC-02 | Detect Obstacle (Front) | Obstacle Sensor |
| SSD-03 | UC-03 | Avoid Front Obstacle | RVC System (UC-02 결과) |
| SSD-04 | UC-04 | Detect Obstacle (Left & Right) | Obstacle Sensor |
| SSD-05 | UC-05 | Avoid All-Direction Obstacle | RVC System (UC-02 + UC-04 결과) |
| SSD-06 | UC-06 | Detect Dust | Dust Sensor |
| SSD-07 | UC-07 | Boost Cleaning Power | RVC System (UC-06 결과) |
| SSD-08 | UC-08 | Handle Sensor Error | Sensor (any) |

---

## SSD-01 : UC-01 Perform Normal Cleaning

> **Actor:** RVC System (자체 시작)  
> **설명:** 장애물·먼지 이벤트 없이 직진하며 청소를 지속 수행

```plantuml
@startuml SSD_01

skinparam sequence {
  ActorBorderColor #1565C0
  ActorBackgroundColor #E3F2FD
  ParticipantBorderColor #5D4037
  ParticipantBackgroundColor #FFFDE7
  LifeLineBorderColor #9E9E9E
  ArrowColor #424242
}
title SSD-01 | UC-01: Perform Normal Cleaning

actor       "RVC System"          as RVC
participant ":RVC Controller SW"  as SYS

RVC -> SYS : startCleaning()
activate SYS

loop [청소 완료 전 — 이벤트 없음]
  SYS -> SYS : pollSensors()
  SYS -> SYS : moveForward()
  SYS -> SYS : clean(powerLevel: NORMAL)
end

deactivate SYS

@enduml
```

![SSD-01: UC-01 Perform Normal Cleaning](diagrams/ssd_01.png)

---

## SSD-02 : UC-02 Detect Obstacle (Front)

> **Actor:** Obstacle Sensor  
> **설명:** 전방 센서가 장애물을 감지하여 Controller에 즉시 전달

```plantuml
@startuml SSD_02

skinparam sequence {
  ActorBorderColor #1565C0
  ActorBackgroundColor #E3F2FD
  ParticipantBorderColor #5D4037
  ParticipantBackgroundColor #FFFDE7
  LifeLineBorderColor #9E9E9E
  ArrowColor #424242
}
title SSD-02 | UC-02: Detect Obstacle (Front)

actor       "Obstacle\nSensor"    as OS
participant ":RVC Controller SW"  as SYS

OS -> SYS : reportObstacle(position: FRONT)

activate SYS
  SYS -> SYS : recordObstacleDetection(position: FRONT)
SYS --> OS : ack()
deactivate SYS

@enduml
```

![SSD-02: UC-02 Detect Obstacle (Front)](diagrams/ssd_02.png)

---

## SSD-03 : UC-03 Avoid Front Obstacle

> **Actor:** RVC System (UC-02 결과로 내부 트리거)  
> **설명:** 전방 장애물 확인 후 정지 → 좌/우 확인 → 회전 → 전진 재개

```plantuml
@startuml SSD_03

skinparam sequence {
  ActorBorderColor #1565C0
  ActorBackgroundColor #E3F2FD
  ParticipantBorderColor #5D4037
  ParticipantBackgroundColor #FFFDE7
  LifeLineBorderColor #9E9E9E
  ArrowColor #424242
}
title SSD-03 | UC-03: Avoid Front Obstacle

actor       "RVC System"          as RVC
participant ":RVC Controller SW"  as SYS

RVC -> SYS : avoidFrontObstacle()
activate SYS

  SYS -> SYS : stopMovement()

  SYS -> SYS : checkSideObstacles()

  alt [LEFT 또는 RIGHT 중 적어도 하나가 비어 있음]
    SYS -> SYS : turnToFreeDirection()
    SYS -> SYS : moveForward()
  else [LEFT·RIGHT 모두 막힘 → UC-05로 위임]
    SYS --> RVC : escalateToAllDirectionAvoid()
  end

deactivate SYS

@enduml
```

![SSD-03: UC-03 Avoid Front Obstacle](diagrams/ssd_03.png)

---

## SSD-04 : UC-04 Detect Obstacle (Left & Right)

> **Actor:** Obstacle Sensor  
> **설명:** 좌·우 센서가 장애물을 감지하여 Controller에 전달 (UC-03·UC-05 방향 결정에 활용)

```plantuml
@startuml SSD_04

skinparam sequence {
  ActorBorderColor #1565C0
  ActorBackgroundColor #E3F2FD
  ParticipantBorderColor #5D4037
  ParticipantBackgroundColor #FFFDE7
  LifeLineBorderColor #9E9E9E
  ArrowColor #424242
}
title SSD-04 | UC-04: Detect Obstacle (Left & Right)

actor       "Obstacle\nSensor"    as OS
participant ":RVC Controller SW"  as SYS

OS -> SYS : reportObstacle(position: LEFT)

activate SYS
  SYS -> SYS : recordObstacleDetection(position: LEFT)
SYS --> OS : ack()
deactivate SYS

OS -> SYS : reportObstacle(position: RIGHT)

activate SYS
  SYS -> SYS : recordObstacleDetection(position: RIGHT)
SYS --> OS : ack()
deactivate SYS

@enduml
```

![SSD-04: UC-04 Detect Obstacle (Left & Right)](diagrams/ssd_04.png)

---

## SSD-05 : UC-05 Avoid All-Direction Obstacle

> **Actor:** RVC System (UC-02 + UC-04 모두 감지 시 내부 트리거)  
> **설명:** 전·좌·우 모두 막힌 경우 후진 → 회전 → 전진 재개

```plantuml
@startuml SSD_05

skinparam sequence {
  ActorBorderColor #1565C0
  ActorBackgroundColor #E3F2FD
  ParticipantBorderColor #5D4037
  ParticipantBackgroundColor #FFFDE7
  LifeLineBorderColor #9E9E9E
  ArrowColor #424242
}
title SSD-05 | UC-05: Avoid All-Direction Obstacle

actor       "RVC System"          as RVC
participant ":RVC Controller SW"  as SYS

RVC -> SYS : avoidAllDirectionObstacle()
activate SYS

  SYS -> SYS : stopMovement()

  SYS -> SYS : moveBackward()

  SYS -> SYS : turnToFreeDirection()

  SYS -> SYS : moveForward()

deactivate SYS

@enduml
```

![SSD-05: UC-05 Avoid All-Direction Obstacle](diagrams/ssd_05.png)

---

## SSD-06 : UC-06 Detect Dust

> **Actor:** Dust Sensor  
> **설명:** 먼지 센서가 먼지를 감지하여 Controller에 즉시 전달

```plantuml
@startuml SSD_06

skinparam sequence {
  ActorBorderColor #1565C0
  ActorBackgroundColor #E3F2FD
  ParticipantBorderColor #5D4037
  ParticipantBackgroundColor #FFFDE7
  LifeLineBorderColor #9E9E9E
  ArrowColor #424242
}
title SSD-06 | UC-06: Detect Dust

actor       "Dust\nSensor"        as DS
participant ":RVC Controller SW"  as SYS

DS -> SYS : reportDust(dustLevel)

activate SYS
  SYS -> SYS : recordDustDetection(dustLevel)
SYS --> DS : ack()
deactivate SYS

@enduml
```

![SSD-06: UC-06 Detect Dust](diagrams/ssd_06.png)

---

## SSD-07 : UC-07 Boost Cleaning Power

> **Actor:** RVC System (UC-06 결과로 내부 트리거)  
> **설명:** 먼지 감지 후 청소 파워 증가 → boostDuration 경과 후 자동 복귀

```plantuml
@startuml SSD_07

skinparam sequence {
  ActorBorderColor #1565C0
  ActorBackgroundColor #E3F2FD
  ParticipantBorderColor #5D4037
  ParticipantBackgroundColor #FFFDE7
  LifeLineBorderColor #9E9E9E
  ArrowColor #424242
}
title SSD-07 | UC-07: Boost Cleaning Power

actor       "RVC System"          as RVC
participant ":RVC Controller SW"  as SYS

RVC -> SYS : boostCleaningPower()
activate SYS

  SYS -> SYS : setCleaningPower(level: BOOSTED)

  SYS -> SYS : setCleaningPower(level: NORMAL)

deactivate SYS

@enduml
```

![SSD-07: UC-07 Boost Cleaning Power](diagrams/ssd_07.png)

---

## SSD-08 : UC-08 Handle Sensor Error

> **Actor:** Obstacle Sensor 또는 Dust Sensor  
> **설명:** 비정상 센서값 수신 시 무시 또는 안전 정지 처리

```plantuml
@startuml SSD_08

skinparam sequence {
  ActorBorderColor #1565C0
  ActorBackgroundColor #E3F2FD
  ParticipantBorderColor #5D4037
  ParticipantBackgroundColor #FFFDE7
  LifeLineBorderColor #9E9E9E
  ArrowColor #424242
}
title SSD-08 | UC-08: Handle Sensor Error

actor       "Sensor (any)"        as SEN
participant ":RVC Controller SW"  as SYS

SEN -> SYS : reportSensorError(sensorId)

activate SYS
  SYS -> SYS : validateSensorData(sensorId)

  alt [일시적 오류 — 단발성 비정상값]
    SYS -> SYS : retainLastValidState()
  else [오류 지속 — SensorStatus → ERROR]
    SYS -> SYS : stopMovement()
  end

deactivate SYS

@enduml
```

![SSD-08: UC-08 Handle Sensor Error](diagrams/ssd_08.png)

---

## System Operations 정의 (최종)

SSD에서 식별된 시스템 오퍼레이션 — Design 단계 `Controller` 인터페이스 후보

| System Operation | 파라미터 | 트리거 | 관련 SSD |
|------------------|----------|--------|---------|
| `startCleaning()` | — | RVC 시작 이벤트 | SSD-01 |
| `reportObstacle(position)` | position: SensorPosition | Obstacle Sensor | SSD-02, SSD-04 |
| `avoidFrontObstacle()` | — | UC-02 결과 (내부) | SSD-03 |
| `avoidAllDirectionObstacle()` | — | UC-02+UC-04 결과 (내부) | SSD-05 |
| `reportDust(dustLevel)` | dustLevel: float | Dust Sensor | SSD-06 |
| `boostCleaningPower()` | — | UC-06 결과 (내부) | SSD-07 |
| `reportSensorError(sensorId)` | sensorId: String | Sensor (any) | SSD-08 |
